#! /bin/bash

# (c) Michael Goetze, 2010-2011, mgoetze@mgoetze.net

error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code

if [ $FAI_ACTION = "install" ]; then
    mount -t proc proc $target/proc
    mount -t sysfs sysfs $target/sys
    [ -L $target/etc/mtab ] || cp /etc/mtab $target/etc/mtab

    cat > $target/etc/sysconfig/network <<-EOF
		NETWORKING=yes
		HOSTNAME=$HOSTNAME.$DOMAIN
		EOF
    echo "127.0.0.1 localhost" > $target/etc/hosts
    ifclass DHCPC || ainsl -s /etc/hosts "$IPADDR $HOSTNAME.$DOMAIN $HOSTNAME"
    cp /etc/resolv.conf $target/etc
fi

mkdir $target/dev/pts
mknod -m 000 $target/dev/pts/ptmx c 5 2

sed -i s/^mirrorlist/#mirrorlist/ $target/etc/yum.repos.d/CentOS-Base.repo
sed -i s/^#baseurl/baseurl/ $target/etc/yum.repos.d/CentOS-Base.repo
sed -i 's/http:\/\/mirror.centos.org/http:\/\/mirrors.aliyun.com/' $target/etc/yum.repos.d/CentOS-Base.repo

$ROOTCMD yum -y install pyliblzma deltarpm
fcopy -riv /etc/yum.repos.d/

# disable the fastestmirror plugin
#sed -i -e 's/enabled=1/enabled=0/' $target/etc/yum/pluginconf.d/fastestmirror.conf

skiptask repository

exit $error
